<?php
//------------------------------------------------------------------------------
// File view list for Thong tin dau tu
// Modification       : V_QuangcaoList
//------------------------------------------------------------------------------
// Date(yyyy.mm.dd)   Developer                       Action
//------------------------------------------------------------------------------
// 2007.03.09         ThanhTX                         Created
//------------------------------------------------------------------------------

function V_QuangcaoList(&$arrayData){
	$ulr = "?".MODUL."=quangcao&".ACTION."=";
	//phan trang
    	$totalRows = 0;
		$paging="";
		$totalRows=count($arrayData);
		$maxRows = MAXROW;
		$maxPages =MAXPAGES;
		if($totalRows%$maxRows==0)
			$totalPages = (int)($totalRows/$maxRows);
		else
			$totalPages = (int)($totalRows/$maxRows+1);
		$curPage =CM_getParameter("curPg");
		if($curPage=="")
			$curPage =1;
		else
			$curRow = ($curPage-1)*$maxRows+1;
		$paging ="Trang thứ :&nbsp;<font color=red>".$curPage."</font>&nbsp;&nbsp;&nbsp;"."Tổng số trang :&nbsp;<FONT color=red>".$totalPages."</FONT><br> ";
		if($totalRows>$maxRows)
		{
			$start=1;
			$end=1;
			$paging1 ="";
			for($i=1;$i<=$totalPages;$i++)
			{
				if(($i>((int)(($curPage-1)/$maxPages))* $maxPages) && ($i<=((int)(($curPage-1)/$maxPages+1))* $maxPages))
				{
					if($start==1) $start=$i;
						if($i==$curPage)
							$paging1 .=  $i."&nbsp;&nbsp;";
						else
							$paging1 .= "<a href='javascript:GotoPage(".$i.")'>".$i."</a>&nbsp;&nbsp;";
					$end=$i;
				}
			}
			$paging.= "Chọn trang :&nbsp;&nbsp;" ;
			if($curPage>$maxPages)
				$paging .="<a href='javascript:GotoPage(".($start-1).")'>Trở về</a>&nbsp;&nbsp;";
			$paging.=$paging1;
			if(((($curPage-1)/$maxPages+1)*$maxPages) < $totalPages)
				$paging .= "<a href='javascript:GotoPage(".($end+1).")'>Tiếp</a>&nbsp;&nbsp;";
		}
?>
<script>
function GotoPage(iPage){
	document.search1.action =document.search1.action  + "&curPg="+iPage;
	document.search1.submit()  ;
}
</script>
<SCRIPT language=javascript src="../javascript/functions.js" type=text/javascript></SCRIPT>
<form name="search1" action="<?=$ulr?>list"  method="post" >
    <table width="100%" border="0" align="center">
	<tbody>
	  <tr>
	  	<td><?= CM_showError() ?></td>
	  </tr>
	 <tr>
	    <td><font size="4" color="#FF0000">Banner quảng cáo:</font>&nbsp;
		<a href="?modul=quangcao&action=Add" class="thanh_link1"><strong><font size="2"> Thêm mới</font></strong></a>
		<br><hr width="20%" size="1" align="left">
		
		</td>
	</tr> 
		
	   <tr>
        <td width="100%">														
				<TABLE border="1" cellpadding="3" cellspacing="0" bordercolor="#FF9900" bordercolordark="white" width="100%">
				  <TBODY>
					  <TR align="center" bgcolor="#FFE59F">
					  	<TD width="24" align="center"><font size="2"><strong>STT</strong></font></TD>
						<TD width="22" align="center"><font size="2"><strong>Sửa</strong></font></TD>  
						<TD width="21" align="center" valign="middle" id=th3><font size="2"><strong>Xóa</strong></font></TD>   
						<TD width="353" align="left"><font size="2"><strong>Tiêu đề</strong></font></TD>
						<TD width="166" align="right"><font size="2"><strong>Thứ tự</strong></font></TD>
						<TD width="105" align="center"><font size="2"><strong>Hiển thị</strong></font></TD>
						<TD width="166" align="right"><font size="2"><strong>Ngày đăng</strong></font></TD>
						<!-- <TD width="173" align="right"><font size="2"><strong>Ngày hết hạn</strong></font></TD> -->
						
				    </TR>
<?				 		$stt=0;
						$i=0;
						$low=$curRow;
						$curRow=1;
						foreach  ($arrayData as $row)
						{
							$stt+=1;
							if($row['hien_thi']==0)
								$strHienthi="Không";
							else
								$strHienthi="Có";
								
							if(($curRow <= $totalRows) && ($curRow <= $curPage*$maxRows))
							{
								$curRow++;
								if($curRow>$low){
									$i+1;
?>			
					  <TR> 
					  	<TD align="center" class=bk12-140 bgcolor="#FFE59F"><font size="2"><?=$stt?></font></TD> 
						<TD width="22" align=middle class=bk12-140 bgcolor="#FFE59F">
							<A  href="<?=$ulr."Edit"?>&id=<? echo $row['id']; ?>&ten=1">
								<IMG   title="Sửa" height=16 alt=Change hspace=2   src="../images/Edit.gif" width=16 border=0>							</A>						</TD>
						<TD align="center" valign="middle" class=bk12-140 bgcolor="#FFE59F">
							<A onclick="return confirmDelete();" 
								href="<?=$ulr."Delete"?>&id=<? echo $row['id']; ?>">
									<IMG title="Xóa" height=16 alt=Drop hspace=2 src="../images/Delete.gif" width=16 border=0>
							</A>
						</TD>
						<TD width="353"class=bk12-140 align="left">
							<font size="2"><? echo $row['ten_doi_tac']; ?></font></TD>        
						<TD width="166" class=bk12-140 align="right"><font size="2"><? echo $row['thu_tu'];?></font></TD>
						
						<TD width="105" class=bk12-140 align="center"><font size="2">
							<a class="thanh_link" href="<?=$ulr."Edit_ht"?>&id=<? echo  $row['id']; ?>&hien_thi=<? echo $row['hien_thi'];?>">
							<?=$strHienthi?>
							</a></font>
						</TD>
						<TD  valign="middle" class=bk12-140>
						<div align="right"><font size="2">
							<? $ngay_dang = substr($row['ngay_dang'],0,10);?>
							<? echo str_replace("-","/",$row['ngay_dang']); ?>
					  </font></div></TD>
					 <!--  <TD  valign="middle" class=bk12-140>
						<div align="right"><font size="2">
							<? //$ngay_het_han = substr($row['ngay_het_han'],0,10);?>
							<? //echo str_replace("-","/",$ngay_het_han); ?>
					  </font></div></TD> -->
					  </TR>				
<?
								}
							}
						} // end foreach  ($arrayData as $row)			
?>
				   </TBODY>
				 </TABLE>
		</td>
		</tr>
	  </tbody>
    </table>
<table border="0" width="99%">
	<!--DWLayoutTable-->
	
	<tr>
		<td width="363" rowspan="2" align=left>
		  <div align="left"><font face="Arial" color="#0066cc">Tổng số bản ghi <b><font color="#ff0000">
			<? echo($totalRows);?></font></b></font></div>
			 <hr width="40%" size="1" align="left">		  
		</td>
		<td width="565" height="23" align=right valign="top"><?=$paging?></td>
	</tr>
	<tr>
	   <td height="15" align="right" valign="top">
		<A class="thanh_link1" href="<?=$ulr."list" ?>">[<strong>Trở về </strong>]</a>&nbsp;&nbsp;&nbsp; 
	   </td>			 
	</tr>
</table>  
<input type=hidden name="textfield" value="<?=CM_getParameter("textfield")?>">
<input type=hidden name="curPg" >
 </form>  
     
<?php
}
?>


	